package com.md.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.md.api.common.utils.StringUtils;
import com.md.api.entity.HttpResult;
import com.md.api.entity.ShoppingCart;
import com.md.api.google.GoogleAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.security.GeneralSecurityException;

@Slf4j
@RequestMapping("/google")
@RestController
public class GoogleController {


	@Resource
	private GoogleAuthService googleAuthService;


	@RequestMapping("/authorizingUrl")
	@ResponseBody
	public HttpResult authorizingUrl(@RequestBody JSONObject json) throws GeneralSecurityException, IOException {
		String s = googleAuthService.authorizingUrl(json);
		return new HttpResult(s);
	}


	@RequestMapping("/authByCode")
	@ResponseBody
	public HttpResult authByCode(@RequestBody JSONObject json) throws GeneralSecurityException, IOException {
		return googleAuthService.authorizing(json);
	}
}
